<include file="default/public/header_common" />
<style>
.check-pay { padding: 20px 0; text-align: center; }
.check-pay p { width: 100%; }
.check-pay button { padding: 10px 20px; }
</style>
<div class="check-pay">
  <if condition="$order.isPay gt 0"> <i class="am-icon-check-circle  am-icon-lg" style="color:#5eb95e; margin-top:30px; font-size:30px;"></i>
    <p class="mt10 mb10">订单支付成功！</p>
    <a href="{:U('Wap/UserOrder/nopayList')}">
    <button type="button" class="am-btn am-btn-warning">查看订单</button>
    </a>
    <else />
    <p style="margin-top:30px; font-size:16px;">订单号：{$order.orderSN}</p>
    <p style="margin-top:10px; font-size:16px;  color:#E71E22;">支付：￥{$order.priceSum}</p>
    <if condition="$order.payType == 2">
      <p style="margin-top:10px;"><a href="">
        <button type="button" class="am-btn am-btn-danger">前往支付宝支付</button>
        </a></p>
      <elseif condition="$order.payType == 3" />
      <p style="margin-top:10px;">
        <button type="button" class="am-btn am-btn-danger" onClick="callpay()">立即支付</button>
      </p>
    </if>
  </if>
</div>
<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
  <div class="am-modal-dialog">
    <div class="am-modal-bd f-small"> 查看订单支付结果 </div>
    <div class="am-modal-footer"> <span class="am-modal-btn" data-am-modal-cancel>支付成功</span> <span class="am-modal-btn" data-am-modal-confirm>支付失败</span> </div>
  </div>
</div>
<script src="__ROOT__/Apps/Wap/View/default/assets/js/jquery.min.js"></script> 
<script src="__ROOT__/Apps/Wap/View/default/assets/js/amazeui.min.js"></script> 
<script type="text/javascript">
function onlinePay() {
	$('#my-confirm').modal({
		relatedElement: this,
		onConfirm: function() {
			window.location = "{:U('Wap/UserOrder/nopayList')}";
		},
		onCancel: function() {
		  location.reload();
		}
	 });
}
</script>
<if condition="$order.isPay == 0 && $order.payType == 3 && !empty($jsApiParameters)"> 
  <script type="text/javascript">
//调用微信JS api 支付
function jsApiCall()
{
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
		{$jsApiParameters},
		function(res){
			WeixinJSBridge.log(res.err_msg);
			if(res.err_msg=='get_brand_wcpay_request:ok'){
	           	alert('恭喜您，支付成功!');
				window.location = "{:U('Wap/UserOrder/noShipping')}";
	       	}else{
	           	alert('支付失败');
				window.location = "{:U('Wap/UserOrder/nopayList')}";
	       	}
		}
	);
}

function callpay()
{
	if (typeof WeixinJSBridge == "undefined"){
		if( document.addEventListener ){
			document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
		}else if (document.attachEvent){
			document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
			document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
		}
	}else{
		jsApiCall();
	}
}
</script> 
</if>
</body></html>